
 <template>
  <div class="price sortPage">
  <pricebar @showbar="tardeNumset" :tardeNum="tardeNum"></pricebar>
    <coll-dom class="ccd" v-show="tardeNum==1"></coll-dom>
    <price-list style="padding-top: 60px;" v-if="tardeNum==1"></price-list>
    <priceselfList v-if="tardeNum==0" :myprice="myprice"></priceselfList>
  </div>
</template>

<script type="text/ecmascript-6">
import collDom from "../../components/price/collapse";
import priceList from "../../components/price/priceList";
import priceselfList from "../../components/price/priceselfList";
import pricebar from "../../components/nav/pricebar.vue";
export default {
  components: {
    collDom,
    priceList,
    pricebar,
    priceselfList
  },
  data() {
    return {
      tardeNum: "f",
      myprice: []
    };
  },
  computed: {
    myslefPrice() {
      return this.$store.state.loginInforXl;
    }
  },
  watch: {
    myslefPrice: {
      //深度监听，可监听到对象、数组的变化
      handler(newV, oldV) {
        this.setSelctpriceID(newV);
      },
      deep: true
    }
  },
 
  methods: {
    tardeNumset(i) {
      this.tardeNum = i;
      this.setSelctpriceID();
    },
    judge() {
      let channel = this.$route.query.channel;
      let islogin = this.$store.state.islogin;
      //判断是否从子频道过来

      if (this.$route.query.menunameflag !== "all") {
        this.tardeNum = 1;
        return;
      }

      //不是子频道过来
      if (islogin) {
        let obj = this.$store.state.loginInforXl;
        if (channel == "tcl" && obj.is_ts == "1") {
          this.myprice = obj.tcl_myprice;
        } else if (channel == "tcl" && obj.is_ts == "0") {
          this.myprice = [];
        } else if (channel == "dc" && obj.is_dc == "1") {
          this.myprice = obj.dc_myprice;
        } else if (channel == "dc" && obj.is_dc == "0") {
          this.myprice = [];
        } else if (channel == "dlg" && obj.is_gt == "1") {
          this.myprice = obj.dlg_myprice;
        } else if (channel == "dc" && obj.is_gt == "0") {
          this.myprice = [];
        }

        if (this.myprice.length > 0) {
          this.tardeNum = 0;
        } else {
          this.tardeNum = 1;
        }
      } else {
        this.tardeNum = 1;
      }
    },
    setSelctpriceID(news) {
      let channel = this.$route.query.channel;
      let obj = news || this.$store.state.loginInforXl;
      if (channel == "tcl") {
        this.myprice = obj.tcl_myprice;
      } else if (channel == "dc") {
        this.myprice = obj.dc_myprice;
      } else {
        this.myprice = obj.dlg_myprice;
      }
    }
  },
  activated() {
    if (!this.$route.meta.back) {
      //不是返回过来的全都要进行重置
     this.judge();
    }
    
  },
};
</script>
<style scoped lang="less">
.price {
  width: 100%;
  min-height: 100%;
  background: #ffffff;
}

.van-dropdown-menu {
  height: 0.88rem;
}
.ccd {
  position: fixed;
  width: 100%;
  top: 46px;
  left: 0;
  background: #ffffff;
  z-index: 111;
}
</style>
